#!/bin/bash

echo "================================================"
echo "清除所有用户数据"
echo "================================================"
echo ""

# 清除后端数据库
echo "[1/2] 清除后端数据库..."
if [ -f "back/users.db" ]; then
    rm -f "back/users.db"
    echo "✅ 后端数据库已删除"
else
    echo "ℹ 后端数据库不存在，跳过"
fi

if [ -f "back/src/main/resources/users.db" ]; then
    rm -f "back/src/main/resources/users.db"
    echo "✅ 后端资源目录数据库已删除"
else
    echo "ℹ 后端资源目录数据库不存在，跳过"
fi

echo ""
echo "[2/2] 前端 localStorage 需要手动清除"
echo ""
echo "📋 请按以下步骤清除前端数据："
echo "   1. 打开浏览器访问 http://localhost:8081"
echo "   2. 按 F12 打开控制台"
echo "   3. 在 Console 中执行以下命令："
echo ""
echo "   localStorage.clear();"
echo "   location.reload();"
echo ""
echo "================================================"
echo "✅ 后端用户数据已清除完成！"
echo "ℹ 请记得清除浏览器的 localStorage"
echo "================================================"
echo ""

